package com.heyukun.hoj.judge.codesandbox;

import com.github.mustachejava.Code;
import com.heyukun.hoj.judge.codesandbox.model.ExecuteCodeRequest;
import com.heyukun.hoj.judge.codesandbox.model.ExecuteCodeResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * 使用代理模式增强代码沙箱的能力
 */
@Slf4j
public class CodeSandBoxProxy implements CodeSandBox {

    private final CodeSandBox codeSandBox;

    /**
     * 定义有参构造
     * @param codeSandBox
     */
    public CodeSandBoxProxy(CodeSandBox codeSandBox){
        this.codeSandBox = codeSandBox;
    }

    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        log.info("代码沙箱请求信息：", executeCodeRequest);
        ExecuteCodeResponse executeCodeResponse = codeSandBox.executeCode(executeCodeRequest);
        log.info("代码沙箱响应信息", executeCodeResponse);
        return executeCodeResponse;
    }

}
